<template>
  <div class="box">
    <van-nav-bar
      title="喜欢的商品"
      left-text="返回"
      right-text="管理"
      left-arrow
      fixed
      @click-left="onClickLeft"
      @click-right="onClickRight"
      class="header"
    />
    <component :is="show"></component>

    <LookLook class="footer-box" />
  </div>
</template>

<script>
import axios from "axios";
import LookLook from "./son-components/LookLook";
import collectionEmpty from "./collections/collectionEmpty";
import collected from "./collections/collected";
export default {
  name: "Collection",
  components: {
    LookLook,
    collectionEmpty,collected
  },
  data() {
    return {
      show: "collectionEmpty",
      arr:[]
    };
  },
  methods: {
    onClickLeft() {
      this.$router.go(-1)
    },
    onClickRight() {},
  },
  created() {
    console.log("this.$route", this.$route.query.id); //匹配到当前路由对象；
    axios({
      url: "/collections"
    }).then((res) => {
      console.log(res.data);
      this.arr=res.data;
     if(this.arr){
       this.show="collected"
     }else{
       this.show="collectionEmpty"
     }
    });
  },
};
</script>

<style scoped>
.box {
  width: 100%;
  height: 100%;
}




</style>
